<?php

/*
 * Created by generator
 *
 */

/**
 * Recupere la liste des enregistrements
 * @param object $db database object
 * @return array of data
 */
if (!function_exists('getAlltrancheAgesFromDB')) {
	function getAlltrancheAgesFromDB($db) {
		$sql = "SELECT traidtra, tralbnom from gyatra order by tralbnom asc";
		$query = $db->query($sql);

		// recuperer les enregistrements
		$records = array();
		foreach ($query->result_array() as $row) {
			$records[] = $row;
		}
		return $records;
	}
}


/**
 * Insere un nouvel enregistrement
 * @param object $db database object
 * @param string ...
 * @return number identifiant
 */
if (!function_exists('insertNewtrancheAge')) {
	function insertNewtrancheAge($db, $tralbnom) {
		$data=array( 'tralbnom'=>$tralbnom );
		$db->insert('gyatra',$data);
		return $db->insert_id();
	}
}

/**
 * Mise a jour d'un enregistrement
 */
if (!function_exists('updatetrancheAge')) {
	function updatetrancheAge($db, $traidtra, $tralbnom) {
		$sql = "update gyatra set tralbnom = ? where traidtra=?";
		$query = $db->query($sql, array($tralbnom, (int)$traidtra ));
	}
}


/**
 * Suppression d'un enregistrement
 */
if (!function_exists('deletetrancheAge')) {
	function deletetrancheAge($db, $traidtra) {
		$sql = "delete from gyatra where traidtra=?";
		$query = $db->query($sql, array((int)$traidtra));
	}
}


/**
 * Recupere les informations d'un enregistrement
 * @param object $db database object
 * @param int id de l'enregistrement
 * @return array
 */
if (!function_exists('gettrancheAgeRow')) {
	function gettrancheAgeRow($db, $traidtra) {
		$sql = "select traidtra, tralbnom from gyatra " .
		"where traidtra=?";
		$query = $db->query($sql, array((int)$traidtra));
		if ($query->num_rows() == 0) {
			return null;
		}
		return $query->row_array();
	}
}

	/***************************************************************************
	 * USER DEFINED FUNCTIONS
	 ***************************************************************************/


?>
